package com.bootdo.app.common.utils;

/**
 * @auther: 作者: Along
 * @description: 手机号掩盖工具类
 * @Date: created in 2019/12/17 12:06
 */
public class ConcealMobileUtil {

    public static String conceal(String str) {
        if (str == null || str.length() < 11) {
            return str;
        }
        StringBuffer sb = new StringBuffer();
        char[] chars = str.toCharArray();
        int index = 0;
        for (char c : chars) {
            if(index < 3 || index > 6){
                sb.append(c);
            }else{
                sb.append("*");
            }
            index++;
        }
        return sb.toString();
    }

}
